local M = {}

M.__index = M 

function M:new(o)

    local o = o or {}
    setmetatable(o, self)
    o:init()
    return o
end 


function M:init()

    self.manager = {}
end 

function M:add(key, value)

    if not key and not value  then 
        return 
    end 
    self.manager[key] = value
end 


function M:get(key)

    if key then 
        return self.manager[key]
    end     
end


-- 判断是否已经存在该userid
function M:is_exist(key)

    for _,v in pairs(self.manager) do 

            if v.userid == key then 
                return true  
            end 
    end 

    return false 
end 


function M:remove(key)

    if key then 
        self.manager[key] = nil 
    end 
end 

function M:count()

    local _count =  0;

    for _,v in pairs(self.manager) do 

        if v then 
            _count = _count + 1
        end 
    end 

    return _count
end 


return M



